<template>
  <el-dialog title="执勤点人员" :visible.sync="dialogvisible" width="750px" append-to-body class="my-dialog"
             :close-on-click-modal="false" @close="cancel">
    <el-form ref="form" :model="form" label-width="90px">
      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="姓名" prop="policeAddress" readonly>
<!--            <el-input v-model="form.nickName" placeholder="请输入人员姓名" readonly disabled/>-->
            {{form.nickName}}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="人员电话" prop="policeName" readonly>
<!--            <el-input v-model="form.phone" placeholder="请输入人员电话"/>-->
            {{form.phone}}
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="职务">
            <el-select
              v-model="form.duties"
              placeholder="请选择职务"
              clearable
              size="small"
            >
              <el-option
                v-for="dict in dict.type.sys_work_post"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
<!--        <el-col :span="12">-->
<!--          <el-form-item label="岗位">-->
<!--            <el-select-->
<!--              v-model="form.duties"-->
<!--              placeholder="请选择职务"-->
<!--              clearable-->
<!--              size="small"-->
<!--            >-->
<!--              <el-option-->
<!--                v-for="dict in dict.type.sys_work_post"-->
<!--                :key="dict.value"-->
<!--                :label="dict.label"-->
<!--                :value="dict.value"-->
<!--              />-->
<!--            </el-select>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
        <el-col :span="12">
          <el-form-item label="调入日期">
            <el-date-picker
              v-model="form.day"
              value-format="yyyy-MM-dd"
              type="date"
              size="small"
              placeholder="请选择"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm" size="small" plain>确 定</el-button>
      <el-button @click="cancel" size="small" plain>取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {updateStagnationPointUser} from "@/api/system/stagnation_point";

export default {
  props: ['visible', 'param', 'isMaster'], // param 执勤点信息
  name: "index",
  dicts: ['sys_work_post'],
  data() {
    return {
      dialogvisible: false,
      form: {},
      zhudian_list: [],
      user_list: [],
      loading_zhudian: false,
      loading_user: false,
      postlist: []
    }
  },
  watch: {
    visible() {
      this.dialogvisible = this.visible
      if (this.visible) {
        console.log('this.param:', this.param)
        let data_ = {
          userId: this.param.userId,
          nickName: this.param.nickName,
          // avatar: this.param.avatar,
          id: this.param.id,
          phone: this.param.phone,
          duties: this.param.duties.toString(), // 职务
          day: this.param.day!=='0'?this.param.day:'', // 日期
          projecIid: this.param.projectId, // 项目id
          pointsId: this.param.pointsId, // 执勤点id
          isMaster: this.isMaster
        }
        this.form = this.$deepCopy(data_)
      } else {
        this.form = {}
      }
    }
  },
  methods: {
    submitForm() {
      console.log('this.form==>', this.form)
      updateStagnationPointUser(this.form).then(res => {
        console.log('res==>', res)
        this.$emit('getList')
        this.cancel()
      })
    },
    cancel() {
      this.$emit('update:visible', false)
    }
  }
}
</script>

<style scoped>

</style>
